﻿using System;
using System.Text.RegularExpressions;

namespace PositiveIntegersExtractor
{
    public class Program
    {
        public static void Main()
        {
            string pattern = @"([^\d-\+]+|((-|\+)\d*(\.\d+)?)|(0\d*(\.\d+)?)|(\d+\.\d+))+";
            string text = @"Write a program that validates real numbers. For example: 0, 33, -2381.78132, 4.3347, 12.00, 0.34 are valid, but +3, 24 543, 01.23, 12., 11,23, --2, .25, -.25 and 12е7 are invalid.";

            Console.WriteLine(text);
            Console.WriteLine("---------------------------");

            Match match = Regex.Match(text, pattern);
            while (match.Success)
            {
                Console.WriteLine("|{0}|", match.Value);
                match = match.NextMatch();
            }
            Console.WriteLine("---------------------------");
            string[] numbers = Regex.Split(text, pattern);
            foreach (String number in numbers)
            {
                Match match2 = Regex.Match(number, pattern);
                if (!match2.Success && number != string.Empty)
                {
                    Console.WriteLine("|{0}|", number);
                }
            }
        }
    }
}
